// /////////////////////////////////////////////////////////////////////////////
//
// Name:            AssetGroup.h
// Author:          Michael Bartsch (ZCCdark203)
//
// Desc :           Declaration of the AssetGroup class.
//
// License:         Copyright (C) 2009 Michael Bartsch and Contributors
//
//                  This program is free software: you can redistribute it
//                  and/or modify it under the terms of the zlib/libpng License.
//                  See main.cpp for conditions of distribution and use.
//
// /////////////////////////////////////////////////////////////////////////////

#ifndef __ASSETGROUP_H__
#define __ASSETGROUP_H__

// Include files
#include "../dependencies.h"
#include "HasEvents.h"
#include "ReferenceCounted.h"

#include "AssetProcessor.h"

// Forward declarations
class AssetProcessor;


// AssetGroup class
//! Represents a collection of assets (meshes, textures, etc).
class AssetGroup : public ReferenceCounted, public HasEvents
{
public:

    // Initialisation and deinitialisation
    //! Constructor
    //! @param name          Name of the asset group.
    //! @param dirName       Name of the base directory of the asset group.
    AssetGroup(const std::string &name, const std::string &dirName);
    //! Deconstructor
    ~AssetGroup();

    //! Initialises the AssetGroup.
    void init();
    //! Clears the AssetGroup.
    void clear();

    // Public methods
    //! Gets the ID of the AssetGroup.
    u32 getID() const;
    //! Gets the name of the AssetGroup.
    const std::string& getName() const;
    //! Gets the base directory of the AssetGroup.
    const std::string& getBaseDir() const;

    //! Gets the AssetProcessor with the given base name.
    //! @param baseName      Basename of the AssetProcessor.
    //! @return Pointer to the AssetProcessor if found, else NULL.
    AssetProcessor* getAssetProcessor(const std::string &baseName);

    //! Reloads the asset with the given name.
    //! @param name          Directory and name (dir/file.*) of the asset.
    bool reloadAsset(const std::string &name);
    //! Reloads all assets in this asset group.
    void reloadAssets();

    //! Removes the asset with the given name.
    //! @param name          Directory and name (dir/file.*) of the asset.
    bool removeAsset(const std::string &name);
    //! Removes all assets.
    void removeAssets();

private:

    // Private methods
    void loadAssets();

    // Static members
    static u32 mIDCount;

    // Private members
    u32 mID;
    std::string mName;
    std::string mBaseDir;

    std::vector<AssetProcessor*> mAssetProcessors;
};

#endif
